import { DriveDirectoryView } from "@/components/drive/DriveDirectoryView"
import { Drive_ls } from "@/lib/drive_server"
import { fetchStorageData } from "@/lib/storage"

export default async function DriveDirectoryPage({
  params,
}: {
  params: Promise<{ path: string[] }>
}) {
  const { path: pathSegments } = await params
  // URL decode each path segment to handle special characters
  const decodedSegments = pathSegments?.map(segment => decodeURIComponent(segment)) || []
  const currentPath = '/' + decodedSegments.join('/')
  
  const [files, storageData] = await Promise.all([
    Drive_ls(currentPath, false),
    fetchStorageData()
  ])
  
  return <DriveDirectoryView path={currentPath} files={files} storageData={storageData} />
}